#include "jian.h"
#include<QMediaPlayer>
#include<QMediaPlaylist>
#include<QString>
#include<QSound>
#include"tui2.h"
jian::jian(QWidget *parent) : QWidget(parent)
{
    b.setText("重新开始");
        connect(&b,&QPushButton::released,this,&jian::rechange);
        b.move(2*64,9*64);
        setWindowTitle("推箱子");
        pBox=new box;
        pMap=new QPainter(this); b.setParent(this);
        setFixedSize(10*64,10*64);

      c.setParent(this);c.setText("结束");
      connect(&c,&QPushButton::released,this,&jian::close);
      c.move(6*64,9*64);
}
void jian::keyPressEvent(QKeyEvent *event)
{
pBox->Key(event);
if(pBox->gameover1()){
    this->close();
}
}

void jian::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
    pMap->begin(this);
    pBox->box::draw(pMap);
    pMap->end();
    QPainter painter(this);QString imgurl;imgurl=":/res/cee82b5e3977bece7fe4b43570459ff.jpg";QImage img(imgurl);
    painter.drawImage(QRect(0,7*64,10*64,3*64),img);
    update();
}

void jian::rechange()
{
    pBox=new box;
    pMap=new QPainter(this);
}
